package com.tutorialspoint;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MainApp {
	 public static void main(String[] args) {
	      ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
	      
//	      XmlBeanFactory factory = new XmlBeanFactory(new ClassPathResource("Beans.xml"));
//	      HelloWorld obj = (HelloWorld) factory.getBean("helloWorld");
//	      HelloWorld obj = (HelloWorld) context.getBean("helloWorld");
	      // test myname
	      // mac ad
	      
//	      obj.getMessage();
//	      obj.setMessage("Hello World! My name is Dayu lu.Nice to meet U!");
//	      obj.getMessage();
//	      obj.setMessage("I'M OBJECT A!");
//	      obj.getMessage();
//	      
//	      HelloWorld objB = (HelloWorld) context.getBean("helloWorld");
//	      objB.getMessage();
	      
	      HelloWorld objA = (HelloWorld) context.getBean("helloWorld");
	      objA.getMessage1();
	      objA.getMessage2();

	      HelloIndia objB = (HelloIndia) context.getBean("helloIndia");
	      objB.getMessage1();
	      objB.getMessage2();
	      objB.getMessage3();
	      
	      ((AbstractApplicationContext) context).registerShutdownHook();
	      
	      
	      TextEditor te = (TextEditor) context.getBean("textEditor");
	      te.spellCheck();
	   }
}
